//
//  UserModel.h
//  youyue
//
//  Created by oceans on 2018/8/16.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

@interface UserCompanyModel : NSObject

@property (copy, nonatomic) NSString *type;
@property (copy, nonatomic) NSString *address;
@property (copy, nonatomic) NSString *name;
- (instancetype)initWithDic:(NSDictionary *)dic;
@end

@interface LoginUser : NSObject

@property (copy, nonatomic) NSString *avatar;
@property (assign, nonatomic) int _id;
@property (copy, nonatomic) NSString *name;
@property (strong, nonatomic) UserCompanyModel *company;
- (instancetype)initWithDic:(NSDictionary *)dic;
@end

typedef void(^LoginSuccessBlock)(void);
typedef void(^LoginFailedBlock)(void);
@interface UserModel : NSObject

@property (strong, nonatomic) LoginUser *loginUser;
@property (assign, nonatomic) BOOL hasLogin;
+ (instancetype)shared;

- (void)loginWithCode:(NSString *)code username:(NSString *)username successBlock:(LoginSuccessBlock)successBlock;

- (void)getCodeWithPhoneNumber:(NSString *)phone scope:(NSString *)scope successBlock:(LoginSuccessBlock)successBlock failedBlock:(LoginFailedBlock)failedBlock;

//- (void)resetPassword:(NSString *)password successBlock:(LoginSuccessBlock)successBlock;

- (void)loginWithDic:(NSDictionary *)userInfo;
- (void)clearWhenLogout;
- (void)logoutSuccessBlock:(LoginSuccessBlock)successBlock;

@property (strong, nonatomic) NSDictionary *userInfo;
- (void)cacheUser:(NSDictionary*)dic;
@end
